package com.jrh.dal;

import java.util.List;
import java.util.Map;

import com.jrh.domain.common.Page;
import com.jrh.domain.entity.Showroom;

/**
 * 样板间DAO
 * 
 * @author yout 2012-7-17 下午6:19:18
 */
public class ShowroomDao extends BaseDao<Showroom> {

    public ShowroomDao(){
        this.namespace = "jrh.single.showroom";
    }
    
    @SuppressWarnings("unchecked")
	public Page<Showroom> listByCondition(Showroom showroom, Integer start, Integer pageSize) {
    	Map<String, Object> map = this.getPageMap(start, pageSize);
    	map.put("name", showroom.getName());
    	map.put("space", showroom.getSpace());
    	map.put("style", showroom.getStyle());
    	map.put("series", showroom.getSeries());
    	List<Showroom> list = (List<Showroom>) sqlMapClientTemplate.queryForList(namespace + "." + "loadByCondition", map);
    	Integer count = (Integer) sqlMapClientTemplate.queryForObject(namespace + "." + "loadByCondition_count", map);
		return new Page<Showroom>(list, start, pageSize, count);
	}
    
    //unused
    @SuppressWarnings("unchecked")
    public List<Showroom> loadByCondition(Showroom showroom) {
        return (List<Showroom>) sqlMapClientTemplate.queryForList(namespace + "." + "loadByCondition", showroom);
    }
    
    @SuppressWarnings("unchecked")
    public List<Showroom> loadByStyle(String style) {
    	return (List<Showroom>) sqlMapClientTemplate.queryForList(namespace + "." + "loadByStyle", style);
    }

    
    @SuppressWarnings("unchecked")
    public List<Showroom> findshowroomid() {
		return  (List<Showroom>) sqlMapClientTemplate.queryForList(namespace + "." + "loadshowroomid");
	}
    public Showroom getShowroomById(Long id){
    	return (Showroom) sqlMapClientTemplate.queryForObject(namespace + "." + "getShowroomById" , id);
    }
    
}
